<template>
	<j-cell title="一键遮蔽" :more="false">
		<view slot="subTitle" style="font-size:24rpx;color:#999999;">打开后,无法观看设备预览画面,设备无法录像</view>
		<view slot="tips" style="padding-right:20rpx;">
			<switch :checked="maskVideo.Enable" @change="change"></switch>
		</view>
	</j-cell>
</template>

<script>
	export default {
	    data() {
	        return {
				maskVideo:false
	        };
	    },
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function (options) {
			this.token = options.token
		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function () {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function () {
			this.getconfig()
		},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function () {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function () {},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function () {},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function () {},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function () {},
		methods: {
			getconfig() {
			    uni.showLoading();
			    let token = this.token;
			    let data = {
						Name: 'General.OneKeyMaskVideo.[0]'
					};
			    getApp().globalData.api.getconfig(data, token, (result) => {
			        uni.hideLoading({
			            success: (res) => {
			                console.log('====================获取配置：', result);
							this.maskVideo = result['General.OneKeyMaskVideo.[0]']
			            }
			        });
			    });
			},
			setconfig() {
			    uni.showLoading();
			    let token = this.token;
			    let data = {
						Name: 'General.OneKeyMaskVideo.[0]',
						'General.OneKeyMaskVideo.[0]':this.maskVideo
					};
			    getApp().globalData.api.setconfig(data, token, (result) => {
			        uni.hideLoading({
			            success: (res) => {
			                console.log('====================设置配置：', result);
			            }
			        });
			    });
			},
			change(ev){
				this.maskVideo.Enable = ev.detail.value
				this.setconfig()
			}
		}
	}
</script>

<style>
</style>
